import pkRequest from '@/service/index'
import type {
  IDoctorSheduleByIdData,
  IFindScheduleListData,
  IHospitalBookingSchedule,
  IHospitalDepartment,
  IHospitalRegister
} from './type'
// 发送网络请求
// 希望拿到的数据类型 具体的数据类型
enum API_HOSPITAL {
  HOSPITAL_RESGITER_URL = '/api/hosp/hospital',
  HOSPITAL_DEPARTMENT_URL = '/api/hosp/hospital/department',
  HOSPITAL_WORK_URL = '/api/hosp/hospital/auth/getBookingScheduleRule',
  HOSPITAL_SCHEDULE_LIST_URL = '/api/hosp/hospital/auth/findScheduleList',
  HOSPITAL_DOCTOR_SCHEDULE_BYID = '/api/hosp/hospital/getSchedule'
}
// 预约挂号：医院信息
export const reqHospitalResgiterData = (hoscode: string) =>
  pkRequest.get<IHospitalRegister>({
    url: API_HOSPITAL.HOSPITAL_RESGITER_URL + `/${hoscode}`
  })
// 预约挂号：科室信息
export const reqHospitalDepartmentData = (hoscode: string) =>
  pkRequest.get<IHospitalDepartment>({
    url: API_HOSPITAL.HOSPITAL_DEPARTMENT_URL + `/${hoscode}`
  })
// 预约挂号 ：获取可预约排班数据
export const reqBookingScheduleData = (
  page: number,
  limit: number,
  hoscode: string,
  depcode: string
) =>
  pkRequest.get<IHospitalBookingSchedule>({
    url:
      API_HOSPITAL.HOSPITAL_WORK_URL + `/${page}/${limit}/${hoscode}/${depcode}`
  })
//预约挂号 : 获取排班数据

export const reqFindDocScheduleListData = (config) => {
  const { hoscode, depcode, workDate } = config
  return pkRequest.get<IFindScheduleListData>({
    url:
      API_HOSPITAL.HOSPITAL_SCHEDULE_LIST_URL +
      `/${hoscode}/${depcode}/${workDate}`
  })
}
// 预约挂号：获取某个医生的信息
export const reqGetDoctorSheduleById = (scheduleId: string) =>
  pkRequest.get<IDoctorSheduleByIdData>({
    url: API_HOSPITAL.HOSPITAL_DOCTOR_SCHEDULE_BYID + `/${scheduleId}`
  })

// pkRequest
//   .request({
//     url: '/api/hosp/hospital/1000_0',
//     interceptors: {
//       requestOnFulfilledFn: (config) => {
//         console.log('@@hospital请求成功的拦截')
//         return config
//       },
//       responseOnFulfilledFn: (res) => {
//         console.log('@@hospital 响应成功的拦截')
//         return res
//       }
//     }
//   })
//   .then((res) => {
//     console.log('hospital', res)
//   })
